<?php
defined('_JEXEC') or die;

require_once 'Mobile_Detect.php';
$detect = new Mobile_Detect;
if( $detect->isMobile() )
{
	include('thankyou_mobile.php');
	return;
}

$sess=JFactory::getSession();
$params=JComponentHelper::getParams('com_questions');

$packcost=array($params->get("price1"), $params->get("price2"), $params->get("price3"), $params->get("price4"));
$packtxt=array("Pakke 1", "Pakke 2", "Pakke 3", "Fitness Pakke");
$fee=$params->get("memberfee");
$orderNo=$sess->get("regs5.on");
$v1=$sess->get('regs1.data');
$v5=$sess->get('regs5.data');
$rabat=0;
if($v5['cp'])
	$rabat=$v5['cp'];
/* lay id_payment moi chen vao */
		$db=JFactory::getDbo();
		$db->setQuery("SELECT id FROM #__users WHERE email=".$db->quote($v1['email']));
		$id_user=$db->loadResult();

		$row_payment=$db->setQuery("SELECT * FROM #__user_payment WHERE id_user=$id_user")->loadObject();
		$tmp=1;
		if($row_payment)
			$tmp=$row_payment->id_package-1;
/* ket thuc */
?>
<div class="wrapper">
				<div class="content clearfix" id="price-page">
					<h1 class="hd">Tak for din ordre</h1>
					<h4 class="mt0 mb10">Ordrenummer: <?php echo $orderNo;?></h4>
					<p class="lh">En ordrebekræftelse vil blive sendt til <?php echo $v1['email']?><br>
					Har du spørgsmål, kan du kontakte os på +45 44 24 24 54<br>
					Alle hverdage mellem kl. 10.00 - 16.00</p>
					<div class="about-info">
						<div class="fl mr27">
							<label>Navn:</label>
							<span><?php echo $v1['fornavn']." ".$v1['efternavn']?></span>
						</div>
						<div class="fl mr27">
							<label>Mobiltelefon :</label>
							<span><?php echo $v1['mobile']?></span>
						</div>
						<div class="clear"></div>
					</div>
					<div>
						<div class="col-box">
							<h1 class="c292929">Pakkevalg</h1>
							<div class="box-temp clearfix">
								<div id="b-1">
								</div>
								<div id="b-2-" class="relative">
									<p class="p-title" style="position: static;margin:0">
									<?php echo $packtxt[$tmp]?>
									</p>
								</div>
							</div>
							<table id="m-table2"><tbody>
<?php
$packid=array(10, 11, 12, 16);

	$db->setQuery("SELECT *
	FROM #__questions_core
	WHERE catid=".$packid[$tmp]);
	$rows = $db->loadObjectList();
	$i=0;

if($tmp)	//text of other packages r suck, must reverse
	$rows=array_reverse($rows);

	foreach($rows as $row){
	?>
<tr<?php if($i) echo " class='even'"?>>
	<td class="t-col-1-">
		<p><a class="tip_trigger" href="#">
		<img src="templates/fitplan/img/imgInfo.png" alt="">
		<span class="tip">
		<?php echo nl2br($row->text);?>
		<span class="arr-left"></span></span>
		</a><?php echo $row->title;?></p>
	</td>
	<td class="t-col-2">
	<?php if($row->published == 1) echo '<img src="templates/fitplan/img/imgCheck-1.png" alt="">'?>
	</td>
</tr>
<?php $i=1-$i;}?>
							</tbody></table>
						</div>
						<div class="col-box">
							<h1 class="c292929">Vælg tilkøb (valgfrit)</h1>
							<div class="clr"></div>
							<table id="m-table3"><tbody>
<?php
//$row_payment=new stdClass;$row_payment->phukiens="1,2,3";
if(!empty($row_payment->phukiens)){

	$row_payment->phukiens=explode(",",$row_payment->phukiens);
	$options=$row_payment->phukiens;
	array_walk($options, function(&$item){$item+=28;});//offset 28 cuz 1st in db is 29
	$options=implode(",",$options);

	$db->setQuery("SELECT text,title,parent FROM #__questions_core WHERE id IN ($options)");
	$rows = $db->loadObjectList();
	$i=0;$j=1;
	foreach($rows as $row){
	?>
<tr<?php if($i) echo " class='even'"?>>
	<td class="t-col-5-1">

		<p>
		<a href="#" title="" class="tip_trigger">
		<img src="templates/fitplan/img/imgInfo.png" alt="">
		<span class="tip">
		<?php echo nl2br($row->text);?>
		<span class="arr-left"></span></span>
		</a><?php echo $row->title;?></p>
	</td>
</tr>
<?php
$i=1-$i;$j++;
	}
}?>
							</tbody></table>
						</div>
						<div class="col-box clearfix">
						<p class="fl"><strong>Du har købt: <span class="ca01b68">
						<?php echo $packtxt[$tmp]?>
						</span></strong></p>
							<p class="fr"><span>Kr. <?php echo $packcost[$tmp]?>,-</span></p>
							<div class="clear"></div>
							<div class="myShopcart clearfix">

								<div class="clearfix ceaeaea">
									<div class="fl">Medlemskab</div>
									<div class="fr">Kr. <?php echo $packcost[$tmp]?>,-</div>
								</div>
								<div class="clearfix">
									<div class="fl">Opstartsgebyr *</div>
									<div class="fr">Kr. <?php echo $fee?>,-</div>
								</div>
<?php if($v5['cp']){$i=0;?>
								<div class="clearfix ceaeaea">
									<div class="fl">Rabat</div>
									<div class="fr">Kr. <?php echo $rabat?>,-</div>
								</div>
<?php }
else
	$i=1;
if($row_payment->phukiens)
foreach($rows as $row){
	echo '<div class="clearfix ',$i ? "ceaeaea" : "",'">
			<div class="fl">',$row->title,'</div>
			<div class="fr">Kr. ',$row->parent,',-</div>
		</div>';
	$i=1-$i;
}
?>
								<div class="clearfix bor-b">
									<div class="fl"><strong>Til betaling om 14 dage *</strong></div>
									<div class="fr"><strong>Kr. <?php echo $row_payment->total ? : $fee+$packcost[$tmp]?>,-</strong></div>
								</div>

								<div class="clearfix">
									<div class="fl">Total første 3 måneder</div>
									<div class="fr"><strong>Kr. <?php echo $row_payment->total ? $row_payment->total+2*$packcost[$tmp] : $fee+3*$packcost[$tmp]?>,-</strong></div>
								</div>
								<div class="clearfix">
									<div class="fl">Restbeløb i bindingsperioden</div>
									<div class="fr"><strong>Kr. <?php echo 2*$packcost[$tmp]?>,-</strong></div>
								</div>

							</div>
						</div>
						<div class="clearfix bor-t pt10">
							<a href="<?php echo JURI::root()?>" class="btnGohome">Til forside</a>
							<a class="fr btnLogin" data-reveal-id="f-login">Log ind</a>
						  <!--   <a href="#" class="btnPrint">Print</a> -->
						</div>

					</div>

					<div class="clear"></div>
				</div>
			</div>
<?php if($orderNo){
	echo '<img src="http://www.partner-ads.com/dk/leadtrack.php?programid=4182&type=lead&uiv=',$orderNo,'" width=1 height=1>';
}?>
<!-- Google Code for Kunder Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 982967144;
var google_conversion_language = "da";
var google_conversion_format = "1";
var google_conversion_color = "ffffff";
var google_conversion_label = "QFpECPDTzgkQ6Mbb1AM";
var google_remarketing_only = false;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/982967144/?label=QFpECPDTzgkQ6Mbb1AM&amp;guid=ON&amp;script=0"/>
</div>
</noscript>